<template>
	<div>
		<van-nav-bar title="推广记录" />
		<van-notice-bar
		:scrollable="false"
		  left-icon="volume-o"
		  :text="statTxt"
		  color="#1989fa" background="#ecf9ff"
		/>
		<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
		  <van-list
		    v-model:loading="loading"
		    :finished="finished"
		    finished-text="没有更多了"
		    @load="onLoad"
		  >
		    <van-cell v-for="item in list" :key="item.id" :title="item.username+ ' '+item.phone" :label="item.area" :value="item.createDate"/>
		  </van-list>
		</van-pull-refresh>
	</div>
</template>

<script type="ts">
export default {
 name: 'bmMy',
};
</script>
<script setup type="ts">
	import {onMounted, ref} from 'vue'
	import {bmList,statBm,saveBm,saveArchive,deleteArchive,getArchive} from '@/api/archives'
	const list = ref([]);
	    const loading = ref(false);
	    const finished = ref(false);
	    const refreshing = ref(false);
	
	    const onLoad = () => {
			if (refreshing.value) {
			  list.value = [];
			  refreshing.value = false;
			}
			loading.value=true;
			bmList({current:1,pageSize:20})
			.then(ret=>{
				list.value=ret.items
				if(ret.currentPage==ret.totalPages)
				{
					finished.value = true;
				}
			})
			loading.value = false; 
	      
	    };
	
	    const onRefresh = () => {
	      // 清空列表数据
	      finished.value = false;
	
	      // 重新加载数据
	      // 将 loading 设置为 true，表示处于加载状态
	      loading.value = true;
	      onLoad();
	    };
		
		//stat
		const stat=ref({
			 count:0
		})
		const statTxt=ref('当前累计填报人数:0人')
		const fetchStat=()=>{
			 statBm()
			 .then(ret=>{
				 stat.value.count=ret.count
				 statTxt.value=`当前累计填报人数:${stat.value.count}人`
			 })
		}
		onMounted(()=>{
			fetchStat()
		})
</script>

<style>
</style>